import http from "@/utils/request";
import type { CourseCategory, CourseCategoryForm, CourseCategoryQueryParams } from "./types";

/**
 * 获取分页列表
 *
 * @param queryParams
 */
export const getCourseCategoryPage = (queryParams: CourseCategoryQueryParams) => {
  return http({
    url: "/api/v1/course-category/page",
    method: "get",
    params: queryParams,
    headers: {
      'Content-Type': 'application/json'
    }
  });
}

/**
 * 获取表单详情
 *
 * @param id
 */
export const getCourseCategoryForm = (id: number) =>{
  return http({
    url: "/api/v1/course-category/getCourseCategoryForm",
    method: "get",
    params: {id: id},
    headers: {
      'Content-Type': 'application/json'
    }
  });
}

/**
 * 添加
 *
 * @param data
 */
export const addCourseCategory = (data: CourseCategory) => {
  return http({
    url: "/api/v1/course-category/add",
    method: "post",
    data: data,
    headers: {
      'Content-Type': 'application/json'
    }
  });
}

/**
 * 修改信息
 *
 * @param data
 */
export const updateCourseCategory = (data: CourseCategoryForm) => {
  return http({
    url: "/api/v1/course-category/update",
    method: "put",
    data: data,
    headers: {
      'Content-Type': 'application/json'
    }
  });
}

/**
 * 删除信息
 * @param id
 */
export const deleteCourseCategory = (id: number) => {
  return http({
    url: "/api/v1/course-category/delete",
    method: "delete",
    data: id,
    headers: {
      'Content-Type': 'application/json'
    }
  });
}

/**
 * 获取所有分类
 */
export const getAllCategory = () => {
  return http({
    url: "/api/v1/course-category/getAllCategory",
    method: "get",
    headers: {
      'Content-Type': 'application/json'
    }
  });
}
